<menu id="8mwcu"></menu>
  • <rt id="8mwcu"><code id="8mwcu"></code></rt><center id="8mwcu"><dd id="8mwcu"></dd></center>
    <center id="8mwcu"></center>
    <dl id="8mwcu"></dl><tbody id="8mwcu"><small id="8mwcu"></small></tbody>
    
    
    <tbody id="8mwcu"></tbody>
     
    技術(shù)博客INFO
    聯(lián)系我們CONTACT

    公司地址:茂名市人民南路新村大院22號101

    電話:13592986386

    網(wǎng)頁微信授權(quán)開發(fā)您當(dāng)前的位置:首頁 > 網(wǎng)頁微信授權(quán)開發(fā)

    網(wǎng)頁微信授權(quán)開發(fā)

    發(fā)布時間:2018/5/15 15:11:31






    Bin 引用DLL

    AppCode引用類文件




     protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                string userAgent = Request.UserAgent;
                if (userAgent.ToLower().Contains("micromessenger"))
                {
                    //Response.Write("歡迎您在微信中訪問我。"); 
                    //code=CODE&state=STATE
                    if (Request.QueryString["code"] != null)
                    {
                        //第一步:定義APPID等
                        string APPID = "*************************";
                        string APPSECRET = "*************************"; ;

                        //第二步:通過code換取網(wǎng)頁授權(quán)access_token
                        string code = Request.QueryString["code"];

                        ZSJson myjson = new ZSJson();
                        string url = "                     string strReturn = myjson.GetFunction(url);
                        JObject jo = JObject.Parse(strReturn);
                        string ACCESS_TOKEN = jo["access_token"].ToString();    //讀取獲取到的ACCESS_TOKEN
                        string OPENID = jo["openid"].ToString();                //讀取獲取到的OPENID
                        Session["openid"] = OPENID;

                        //第四步:拉取用戶信息(需scope為 snsapi_userinfo)
                        string nexturl = "
                        string nextstrReturn = myjson.GetFunction(nexturl);
                        //Response.Write(nextstrReturn);
                        JObject result = JObject.Parse(nextstrReturn);
                        string nickname = result["nickname"].ToString();
                        string sex = result["sex"].ToString();
                        string headimgurl = result["headimgurl"].ToString();
                        string province = result["province"].ToString();
                        string city = result["city"].ToString();


                        /************業(yè)務(wù)邏輯(默認(rèn)注冊帳號,注冊完成后進(jìn)入某個指定頁面)****************************/
                        string Password = "123456";                           //密碼
                        string cMD5Pass = FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "MD5");  //MD5加密
                        SqlConn mysql = new SqlConn();
                        Hashtable httParam = new Hashtable();
                        httParam.Add("@OPType", 777);
                        httParam.Add("@iRole", 1);
                        httParam.Add("@OPENID", OPENID);
                        httParam.Add("@cUserName", nickname);
                        httParam.Add("@cMobile", "");
                        httParam.Add("@cPic", headimgurl);
                        httParam.Add("@cPassword", cMD5Pass);
                        string StoredtName = "tb_User_Proc";
                        DataTable dt = mysql.ExecuteDataTable(StoredtName, httParam, CommandType.StoredProcedure);
                        if (dt.Rows.Count > 0)
                        {
                            CookieManage mycookies = new CookieManage();
                            mycookies.DeleteCookie("UserID");
                            mycookies.DeleteCookie("UserName");
                            mycookies.DeleteCookie("UserMobile");

                            int cookiestime = 1440;
                            mycookies.WriteCookie("UserID", dt.Rows[0]["ID"].ToString(), cookiestime, true);
                            mycookies.WriteCookie("UserName", dt.Rows[0]["cUserName"].ToString(), cookiestime, true);
                            mycookies.WriteCookie("UserMobile", dt.Rows[0]["cMobile"].ToString(), cookiestime, true);

                            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language=javascript>autoPage()</script>");
                        }
                        /*************************************/
                    }
                    else
                    {
                        //第一步:用戶同意授權(quán),獲取code
                        //在確保微信公眾賬號擁有授權(quán)作用域(scope參數(shù))的權(quán)限的前提下(服務(wù)號獲得高級接口后,默認(rèn)擁有scope參數(shù)中的snsapi_base和snsapi_userinfo),引導(dǎo)關(guān)注者打開如下頁面:
                        string APPID = "*************************";
                        string webdomain = "http://" + HttpContext.Current.Request.Url.Host;
                        string REDIRECT_URI = webdomain + "/Default.aspx";
                        string url = "
                        Response.Redirect(url);
                    }
                }
                else
                {
                    //非微信瀏覽器打開(電腦,手機(jī)瀏覽器)
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language=javascript>autoPage()</script>");
                }
            }
        }

    美丽人妻中文字幕中出在线,97婷婷视频在线,亚洲精品午夜无码专区,人人九九精品国产 国产黄色视频在线播 亚洲精品91天天久久人人
    <menu id="8mwcu"></menu>
  • <rt id="8mwcu"><code id="8mwcu"></code></rt><center id="8mwcu"><dd id="8mwcu"></dd></center>
    <center id="8mwcu"></center>
    <dl id="8mwcu"></dl><tbody id="8mwcu"><small id="8mwcu"></small></tbody>
    
    
    <tbody id="8mwcu"></tbody>